package org.luxor.commons.elasticsearch.metadata;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * @author Mr.Yan  @date 2019/9/26$
 */
@ApiModel(description = "分页查询")
public class EsPageQuery<T> implements Serializable {

    @ApiModelProperty(value = "scroll分页快照Id", example = "1")
    private String scrollId;

    @ApiModelProperty(value = "当前页数", example = "1")
    private int current = 1;

    @ApiModelProperty(value = "每页记录数", example = "10")
    private int size = 10;

    @ApiModelProperty(value = "搜索条件", example = "{'status':'1'}")
    private T search;

    @ApiModelProperty(value = "排序条件", example = "[{'column':'id','asc':true},{'column':'name','asc':true}]")
    private EsOrderItem orders;

    public EsPageQuery() {
        super();
    }

    public String getScrollId() {
        return scrollId;
    }

    public void setScrollId(String scrollId) {
        this.scrollId = scrollId;
    }

    public int getCurrent() {
        return current < 1 ? 1 : this.current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public T getSearch() {
        return search;
    }

    public void setSearch(T search) {
        this.search = search;
    }

    public EsOrderItem getOrders() {
        return orders;
    }

    public void setOrders(EsOrderItem orders) {
        this.orders = orders;
    }

    @Override
    public String toString() {
        return "EsPageQuery{" +
                "scrollId='" + scrollId + '\'' +
                ", current=" + current +
                ", size=" + size +
                ", search=" + search +
                ", orders=" + orders +
                '}';
    }
}
